package logins;

import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.ServletActionContext;

public class addprocess {

    private String Account;
    private String Password;
    private String Name;
    private int Sex;
    private String Birth;
    private String County;
    private String Region;
    private String Address2;
    private String Address;
    private String Phone;
    private String Email;
    private String VaildNumText;

    public addprocess() {
    }

    public String execute() throws Exception {
        String result = "fail";

        NWDB.NWDB mydb = new NWDB.NWDB();
        NWDB.ImplMember im = new NWDB.ImplMember(mydb.getConnection());
        mydb.setIMember(im);

        HttpServletRequest request = ServletActionContext.getRequest();
        //if (request.getSession().getAttribute("randomString").toString().equalsIgnoreCase(VaildNumText)) {
            try {
                Address2 = County + Region + Address;
                mydb.AddNewMember(Account, Password, Name, Sex, Birth, Address2, Phone, Email);
                result = "success";
            } catch (Exception e) {
                result = "fail";
            }
        //}
        /*else{
            result="fail"; 
            request.setAttribute("message", "驗證碼錯誤！");
        }*/

        return result;
    }

    public String getAccount() {
        return Account;
    }

    public void setAccount(String Account) {
        this.Account = Account;
    }

    public String getPassword() {
        return Password;
    }

    public void setPassword(String Password) {
        this.Password = Password;
    }

    public String getName() {
        return Name;
    }

    public void setName(String Name) {
        this.Name = Name;
    }

    public int getSex() {
        return Sex;
    }

    public void setSex(int Sex) {
        this.Sex = Sex;
    }

    public String getBirth() {
        return Birth;
    }

    public void setBirth(String Birth) {
        this.Birth = Birth;
    }

    public String getAddress() {
        return Address;
    }

    public void setAddress(String Address) {
        this.Address = Address;
    }

    public String getPhone() {
        return Phone;
    }

    public void setPhone(String Phone) {
        this.Phone = Phone;
    }

    public String getEmail() {
        return Email;
    }

    public void setEmail(String Email) {
        this.Email = Email;
    }

    public String getCounty() {
        return County;
    }

    public void setCounty(String County) {
        this.County = County;
    }

    public String getRegion() {
        return Region;
    }

    public void setRegion(String Region) {
        this.Region = Region;
    }

    public String getVaildNumText() {
        return VaildNumText;
    }

    public void setVaildNumText(String VaildNumText) {
        this.VaildNumText = VaildNumText;
    }

}
